package edu.sdjzu.exam.controller;

import edu.sdjzu.exam.dto.examSession.ExamSessionDTO;
import edu.sdjzu.exam.service.examSession.ExamSessionService;
import lombok.RequiredArgsConstructor;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;

import java.util.List;

@Controller
@RequiredArgsConstructor
public class ExamWebSocketController {

    private final ExamSessionService examSessionService;

    @MessageMapping("/monitor/{examId}")
    @SendTo("/topic/exam/{examId}")
    public List<ExamSessionDTO> monitorExamSessions(Long examId) {
        return examSessionService.monitorExamSessions(examId);
    }
}
